package server;

public class DatabaseRebuild {

    public static void main(String[] args) {
        DBAccess DBA = new DBAccess();
        DBA.InitDBConnection();
        
	    String users_query = "CREATE TABLE USERS (USERNAME VARCHAR(50) NOT NULL," +
        "PRIMARY KEY (USERNAME), " +
        "PASSWORD VARCHAR(50) NOT NULL, " +
        "RATING INT UNSIGNED NOT NULL, " +
        "EMAIL VARCHAR(50))";
		
		String history_query = "CREATE TABLE GAME_HISTORY (GAME_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, " +                           
		    "USERNAME VARCHAR(50) NOT NULL, " +
		    "OPPONENTS VARCHAR(256) NOT NULL, " +
		    "RATING_CHANGE INT NOT NULL, " +
		    "GAME_DATE DATE NOT NULL, " +
		    "PRIMARY KEY (GAME_ID), " +
		    "Foreign Key (USERNAME) references USERS(USERNAME))";
		
		String hof_query = "CREATE TABLE HALL_OF_FAME (USERNAME VARCHAR(50) NOT NULL," +
		        "SCORE INT UNSIGNED NOT NULL)";
		
		DBA.WriteToDB("DROP TABLE HALL_OF_FAME");
		DBA.WriteToDB("DROP TABLE GAME_HISTORY");
		DBA.WriteToDB("DROP TABLE USERS");
		DBA.WriteToDB(users_query);
		DBA.WriteToDB(history_query);
		DBA.WriteToDB(hof_query);
        
                
        DBA.ShutDBConnection();
    }
}
